package com.gljx.web.service.impl;

import java.util.List;

import com.gljx.util.GetFid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.gljx.web.Entity.ExerciseCarPlanCoach;
import com.gljx.web.Entity.ExerciseCarPlanEntry;
import com.gljx.web.dao.CommonDao;
import com.gljx.web.dao.ExerciseCarPlanEntryMapper;
import com.gljx.web.service.ExerciseCarPlanEntryService;

@Service
@Transactional
public class ExerciseCarPlanEntryServiceImpl extends CommonDao implements ExerciseCarPlanEntryService{

	@Autowired
	private ExerciseCarPlanEntryMapper exerciseCarPlanEntryMapper;
	
	
	/**
	 * 实现添加
	 */
	@Override
	public void addExerciseCarPlanEntry(ExerciseCarPlanEntry exerciseCarPlanEntry) {
		// TODO Auto-generated method stub
        //先查询子表记录

        if ("null".equals(exerciseCarPlanEntry.getFid())) {
            //插入
            exerciseCarPlanEntry.setFid(GetFid.UUIDIntoFid());
            exerciseCarPlanEntryMapper.insertSelective(exerciseCarPlanEntry);
        } else {
            exerciseCarPlanEntryMapper.updateByPrimaryKeySelective(exerciseCarPlanEntry);
        }
        //
	}

	/**
	 * 实现根据父类id删除
	 */
	@Override
	public void deleteByFparentid(String fparentid) {
		// TODO Auto-generated method stub
		exerciseCarPlanEntryMapper.deleteByFparentid(fparentid);;
	}

	/**
	 * 根据父类id查询
	 */
	@Override
	public List<ExerciseCarPlanEntry> queryByFparentid(String fparentid) {
		// TODO Auto-generated method stub
		return exerciseCarPlanEntryMapper.selectByFparentid(fparentid);
	}

	/**
	 * 实现根据fid修改
	 */
	@Override
	public void modifyExerciseCarPlanEntry(ExerciseCarPlanEntry entry) {
		// TODO Auto-generated method stub
		exerciseCarPlanEntryMapper.updateByPrimaryKeySelective(entry);
	}

	@Override
	public void addExerciseCarPlanCoach(ExerciseCarPlanCoach exerciseCarPlanCoach) {
		// TODO Auto-generated method stub
		exerciseCarPlanEntryMapper.insertCoach(exerciseCarPlanCoach);
	}

	@Override
	public List<ExerciseCarPlanCoach> queryExerciseCarPlanCoach(String fparentid) {
		// TODO Auto-generated method stub
		return exerciseCarPlanEntryMapper.selectExerciseCarPlanCoach(fparentid);
	}

	@Override
	public void deleteExerciseCarPlanCoach(String fparentid) {
		// TODO Auto-generated method stub
		exerciseCarPlanEntryMapper.deleteExerciseCarPlanCoach(fparentid);
	}

    @Override
    public void deleteByFid(String fid1) {
        exerciseCarPlanEntryMapper.deleteByPrimaryKey(fid1);
    }

}
